package com.example.demo.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.common.Result;
import com.example.demo.entity.Desk;
import com.example.demo.mapper.DeskMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class DeskService {
    @Resource
    DeskMapper deskMapper;

    public Result<?> save(Desk desk) {
        deskMapper.insert(desk);
        return Result.success();
    }

    public Result<?> updateOne(Desk desk) {
        deskMapper.updateById(desk);
        return Result.success();
    }

    public Result<?> deleteOne(Desk desk) {
        deskMapper.deleteById(desk);
        return Result.success();
    }

    public List<Desk> findAll() {
        return deskMapper.selectList(null);
    }

    public List<Desk> findPagain() {
        deskMapper.selectPage(new Page<>(1, 10), Wrappers.<Desk>lambdaQuery().like(Desk::getName, '好'));
        return null;
    }

}
